<?php
set_time_limit(0);
$start = microtime(1);
require '../inc/inc.php';
//header('content-type:text/plain;charset=utf-8');
header('content-type:text/html;charset=utf-8');
echo '<pre>', "\n";
if (empty($_SESSION['uid'])) {
//	User::login('tt', 'tt');
//	header('Location: http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
//	exit;
	$uid = 113;
} else {
	$uid = $_SESSION['uid'];
}

echo PHP_VERSION,"\n\n";

//define('IN_UC', true);
//require_once 'api/ucenter/uc.php';
//$ret = _authcode($_COOKIE['uc_auth'], 'DECODE');
//var_export($ret);
//exit;


//$sql = 'select depot_id,item_id from depot';
//$list = $DB->getList($sql);
////var_export($list);
//$sql = '';
//$cropList = C('item/crop');
//$fruitList = C('item/fruit');
//$animalList = C('item/animal');
//$gatherList = C('item/gather');
//foreach ($list as $v) {
//	if ($v['item_id'] == 100) {
//		$skillId = 0;
//	} else if ($v['item_id'] < 100) {
//		$skillId = $cropList[$v['item_id']]['skill_id'];
//	} else if ($v['item_id'] < 200) {
//		$skillId = $fruitList[$v['item_id']]['skill_id'];
//	} else if ($v['item_id'] < 300) {
//		$skillId = $animalList[$v['item_id']]['skill_id'];
//	} else if ($v['item_id'] < 400) {
////		var_export($v['item_id']);
////		continue;
//		$skillId = $animalList[$v['item_id']-100]['skill_id'];
//	} else if ($v['item_id'] > 400 && $v['item_id'] < 500) {
//		$skillId = $gatherList[$v['item_id']]['skill_id'];
//		if ($v['depot_id'] == 310) {
//		var_export($gatherList[$v['item_id']]);
//		echo "\n";
//		}
//	} else {
//		$skillId = 0;
//	}
//	$sql .= "update depot set skill_id={$skillId} where depot_id={$v['depot_id']};";
//}
//$DB->exeSql($sql);
//exit;




//include 'api/ucenter/config_ucenter.php';
//include 'api/ucenter/uc_client/client.php';
//$sql = 'SELECT uid,username,email FROM user where uid>2';
//$userList = $DB->getList($sql);
//
//foreach ($userList as $u) {
////	$u['username'] = 'v1';
//	$u['email'] = 'random'.$u['uid'].'@qq.com';
//	$uid = uc_user_register($u['username'], '333', $u['email']);
//	if($uid <= 0) {
//		if($uid == -1) {
//			echo '用户名['.$u['username'].']不合法';
//		} elseif($uid == -2) {
//			echo '包含要允许注册的词语';
//		} elseif($uid == -3) {
//			echo '用户名已经存在';
//		} elseif($uid == -4) {
//			echo 'Email 格式有误';
//		} elseif($uid == -5) {
//			echo 'Email 不允许注册';
//		} elseif($uid == -6) {
//			echo '该 Email 已经被注册';
//		} else {
//			echo '未定义';
//		}
//		exit;
//	} else {
//		$sql = 'update user set uc_uid='.$uid.' where uid='.$u['uid'];
//		$DB->exeSql($sql);
//	}
//}
//
//exit;







//session_start();
//var_export($_COOKIE);
//var_export($_SESSION);
//exit;



//$staffNameList = C('making/staff_name');
//$start = microtime(1);
//for ($i=0; $i<=10000; $i++) {
//	$key = array_rand($staffNameList['family_name']);
//	$name = $staffNameList['family_name'][$key];
//}
//echo microtime(1) - $start;
//echo "\n";
//
//$start = microtime(1);
//for ($i=0; $i<=10000; $i++) {
//$cnt = count($staffNameList['family_name']);
//$key = rand(0, $cnt-1);
//$name = $staffNameList['family_name'][$key];
//}
//echo microtime(1) - $start;
//exit;

//$start = microtime(1);
//$a = array(// 增加属性类型
//	4101,
//	4102,
//	4103,
//	4104,
//	4105,
//	4106,
//	4107,
//	4108,
//	4109,
//);
//for ($i=0; $i<10000; $i++) {
//	$k = array_rand($a);
//	$v = $a[$k];
//}
//echo microtime(1) - $start;
//echo "\n\n";
//echo $v;
//echo "\n\n";
//
//for ($i=0; $i<10000; $i++) {
//	$num = count($a);
//	$k = rand(0, $num-1);
//	$v = $a[$k];
//}
//echo microtime(1) - $start;
//echo "\n\n";
//echo $v;
//echo "\n\n";
//exit;

//date_default_timezone_set('Asia/Shanghai');
//echo time();
//echo "\n";
//echo date('Y-m-d H:i:s');
//echo "\n";
//echo "\n";
//
//date_default_timezone_set('PRC');
//echo time();
//echo "\n";
//echo date('Y-m-d H:i:s');
//echo "\n";
//echo "\n";
//
//date_default_timezone_set('UTC');
//echo time();
//echo "\n";
//echo date('Y-m-d H:i:s');
//echo "\n";
//echo "\n";
//exit;






//$time = strtotime("this week Tuesday");
//echo $time, "\n";
//echo date('Y-m-d H:i:s', $time), "\n";
//exit;


//for ($i=0; $i<10; $i++) {
//	echo pow($i+2, 3)*5 - pow($i+1, 3)*5 + rand(($i+1)*5, ($i+1)*5);
//	echo "\n";
//}
//exit;

//$arr = array(5, 10, 15);

//echo strtr('2010年12月11日07:04', array('年'=>'-', '月'=>'-', '日'=>' '));
//exit;

//$time = strtotime('today');
//echo date('Y-m-t +1 \d\a\y\s');
//echo "\n";
//$time = strtotime('last monday');
//$time = strtotime(date('Y-m-d H').':0:0 +1hours');
//$time = strtotime(date('Y-m-d H:0'));
//echo date('Y-m-d H:i:s', $time), "\n";
//exit;

echo time();
echo "\n";
echo date('Y-m-d H:i:s'), "\n";
//echo date('Y-m-d H:i:s', 1312435363);
echo "\n";
//exit;
//$_SESSION = array();
var_export($_COOKIE);
echo "\n\n";
var_export($_SESSION);
echo "\n\n";
$username = 'test';
//$ret = User::isUserExists($username);
$nickname = 'tss';
$sex = 1;
$city = 'tss';
//$ret = User::createRole($nickname, $sex, $city);
//var_export($ret);
//exit;








//echo time();
//echo "\n";
echo "\n\n\n";

//echo urldecode('&');
$times = 0;


//while(true) {
//	$times++;
//	$list = array();
//	for ($i=0; $i<8; $i++) {
//		$list[] = rand(5, 10);
//	}
//	$a = array_sum($list);
//	$b = 70 - $a;
//	if ($b > 5 && $b < 10) {
//		$list[] = $b;
//		break;
//	}
//	if ($times > 1000) {
//		break;
//	}
//}
//var_export($list);
//echo $times;
//exit;





//$ret = Prison::detain($uid);
//var_export($ret);







//$ret = User::initUserProficiency($uid);
//$ret = User::getProficiencyList($uid);
//$ret = User::isCreatedRole($uid);
$ret = User::getFileterList($uid);
var_export($ret);
//exit;


//$ret = SGame::loadCfg('common');
//var_export($ret);
//exit;

$type = 53;
//$ret = Bag::getList($uid, $type);
//$ret = Bag::getFreeGrid($uid);
//$uid = 1;
$bag_id = 70;
//$ret = Bag::trash($uid, $bag_id);
//var_export($ret);
//exit;


//$ret = Depot::getFreeGrid($uid);
//var_export($ret);
//exit;

$item_id = 10121;
$item_id = 10014;
$friendList = array(1);
//$ret = Gift::present($uid, $friendList, $item_id);
//var_export($ret);
//exit;


$item_id = 11006;
$lvl = 0;
$class = null;
//$ret = TreasureBox::get($uid, $item_id, $lvl, $class);
$bag_id = 227;
//$ret = TreasureBox::open($uid, $bag_id);
$bag_id = 200;
$friendList = array(
	2,
	3,
//	4,
	86,
//	46
);
//$ret = TreasureBox::share($uid, $bag_id, $friendList);
//$ret = TreasureBox::getFriendList($uid);
//var_export($ret);
//exit;



//$m->set('ui', 100);
//$ret = $m->get('chatLog');
//var_export($ret);
//exit;
//$_SESSION['uchatindex'] = 1;
//exit;


//$uid = 93;
$channel = 'private';
$content = 'liaolaio';
$object = 'tt';
//$ret = Chat::send($uid, $channel, $content, $object);
echo "\n";
$index = 0;
//$ret = Chat::getMsg($uid);
//$ret = User::filter($uid, '1233ret', array());
//var_export($ret);
//exit;

//$uid = 86;
$to_nickname = 'test';
$content = 'test...test...again...';
$type = 1;
$attachment = array(
	array(
		'item_id'	=> 65535,
		'num'		=> 500
	),
	array(
		'item_id'	=> 10021,
		'num'		=> 1
	),
	array(
		'item_id'	=> 2301,
		'num'		=> 1,
		'part'		=> 1,
		'color'		=> 3,
		'inlay'		=> '{"1":[],"2":[],"3":{"4102":2}}',
		'attr'		=> '4101=18'
	),
);
//$ret = Mail::send($uid, $to_nickname, $content, $type, $attachment);
$uid = 117;
$to_nickname = 'tt';
//$content = '3432432';
//$ret = Mail::send($uid, $to_nickname, $content);
//$ret = Mail::getList($uid);
$m_id = 200;
//$ret = Mail::read($uid, $m_id);
//$uid = 113;
$m_id = 88;
$key = 0;
//$ret = Mail::fetchAttachment($uid, $m_id, $key);
//var_export($ret);
//exit;



//$ret = PropsBox::getList($uid);
//var_export($ret);
//exit;


$staff_id = 1;
$equip_id = 238;
//$ret = Equip::getEquipOnBodyList($uid, $staff_id);
//$ret = Equip::putOn($uid, $staff_id, $equip_id);
//$ret = Equip::takeOff($uid, $staff_id, $equip_id);
$luck_times = 2;
//$ret = Equip::strengthen($uid, $equip_id, $luck_times);
$gemList = array(159, 160);
//$ret = Equip::gemMix($uid, $gemList);
$gem_id = array(112 => 1, 205 => 2);
//$ret = Equip::inlay($uid, $equip_id, $gem_id, 3);
//$ret = Equip::getInfo($uid, $equip_id);
//var_export($ret);
//exit;

$class = 101;
//$ret = Staff::add($uid, $class);
//$ret = Staff::getInfo($uid, $class);
$staff_id = 1;
//$ret = Staff::getInfoById($uid, $staff_id);
//$ret = Staff::getDefaultCardList($uid);
//$uid = 108;
//$staff_id = 63;
//$card_id = 0;
//$pos = 1;
//$item_id = 10021;
//$ret = Staff::putOnCard($uid, $staff_id, $card_id, $pos, $item_id);
//$card_id = 0;
//$pos = 1;
//$item_id = 10021;
//$ret = Staff::putOnCard($uid, $staff_id, $card_id, $pos, $item_id);
//$ret = Staff::refreshStateVal($uid, $staff_id);
$staff_id = 65;
$exp = 411;
//$ret = Staff::addExp($uid, $staff_id, $exp);
$abi_id = 4101;
//$ret = Staff::advStudy($uid, $staff_id, $type);
$point_num = 10;
//$ret = Staff::train($uid, $staff_id, $abi_id);
//$ret = Staff::getArenaList($uid, $class);
//$uid = 108;
//$staff_id = 63;
//$target_staff_id = 45;
//$ret = Staff::pk($uid, $staff_id, $target_staff_id);
$spl_id = 42;
//$ret = Staff::getPkResultInfo($uid, $spl_id);
$no_choice = array(3,2,4,5);
$spl_id = 1;
//$ret = Staff::getPkPrize($uid, $spl_id, $no_choice);
//$staff_id = 47;
//$uid = 99;
//$ret = Staff::getPkLogList($uid, $staff_id);
//$ret = Staff::getPkMessage($uid);
$class = 102;
//$ret = Staff::getData($uid, $class);
//var_export($ret);
//exit;

//$ret = Friend::add($uid, $touid);
$fuid = 2;
//$ret = Friend::delete($uid, $fuid);
$friend_id = 2;
//$ret = Friend::getFriendlyVal($uid, $friend_id);
//$ret = Friend::getList($uid);
//var_export($ret);
//exit;


//$ret = Market::init();
$title = '';
//$ret = Market::getList($uid, 0, null, $title, 0, 1);
$depot_id = 91;
$num = 5;
$price = 6;
//$ret = Market::sale($uid, $depot_id, $num, $price);
//$ret = Market::getShelfList($uid);
$item_id = 100;
$quality = 1;
//$ret = Market::getUserSaleList($uid, $item_id, $quality);
//$ret = Market::undersell($uid, 7);
$mk_id = 307;
//$num = 4;
$num = 'a';
$mk_id = 1;
$num = 1;
//$ret = Market::buy($uid, $mk_id, $num);
//$ret = Market::handleEndSale($uid);
$mus_id = 19;
$num = 1;
//$ret = Market::buyFromUser($uid, $mus_id, $num);
//var_export($ret);
//exit;


//
//exit;
$skillId = 1001;
//$ret = Skill::study($uid, $skillId);
//$ret = Skill::isStudied($uid, $skillId);
//var_export($ret);


$elf_id = 1;
$attr = array(
	'lvl' => 30
);
//$ret = Elf::create($uid, $elf_id, $attr);
$elf_id = 1;
$defense_elf_id = 2;
//$ret = Elf::fight($uid, $elf_id, $defense_elf_id);
$nodalPointData = array(
	'area'  => 1,
	'point' => 1,
);
$start = microtime(1);
echo "\n";
//$ret = Elf::fightMonster($uid, array($elf_id), $nodalPointData);
//echo microtime(1)-$start;
//echo "\n";
//exit;
//$ret = Elf::getAllSkillList();
$skillId = 2;
//$ret = Elf::studySkill($uid, $skillId);
$elf_id = 1;
//$ret = Elf::indueSkill($uid, $skillId, $elf_id);
//var_export($ret);
//exit;

//$list = array(
//	1 => 15,
//	2 => 35,
//	3 => 0,
//);
//$ret = getRandResult($list);
//var_export($ret);
//echo date('Y-m-d H:i:s', 1305712596);
//exit;

//$ret = Shop::create($uid);
//echo time();
//$ret = Shop::sale($uid, $sd_id);
//$ret = Shop::addQueuePos($uid);
//$ret = Shop::addSalePos($uid);
//$ret = Shop::addQueueGuest($uid);
//$uid = 108;
//$ret = Shop::getQueueList($uid);
$queuePos = 1;
$salePos = 1;
//$ret = Shop::moveQueue2sale($uid, $queuePos, $salePos);
//$depot_id = 773;
//$ret = Shop::buy($uid, $salePos, $depot_id);
//$ret = Shop::getQueueList($uid);
//$ret = Shop::getSaleList($uid);
//$uid = 130;
//$pos = 2;
//$to_uid = 108;
//$ret = Shop::getCoin($uid, $pos, $to_uid);
//$ret = Shop::getDepotFreeSpace($uid);
//$uid = 85;
//$pos = 1;
//$ret = Shop::lvlUpSalePos($uid, $pos);
//$ret = Shop::lvlUpQueuePos($uid, $pos);
$ussa_id = 167;
//$ret = Shop::clearRubbish($uid, $ussa_id);
//$ret = SShop::getDepotSpaceNum($uid);
//$uid = 130;
//$friend_id = 138;
//$queuePos = 2;
//$ret = Shop::lureGuest($uid, $friend_id, $queuePos);
//var_export($ret);
//exit;

//$ret = Uptown::init(1);


$class = 102;
//$uid = 2;
//$ret = Making::open($uid, $class);
$product = 1;
//$uid = 108;
//$type = 101;
//$ret = Making::getInfo($uid, $type);
//$ret = Making::lvlUp($uid, $type);
$technics = 1;
$param = 1;
$main_mat = array(1 => 5, 2=>3, 33=>2, 61=>3, 274=>5);
$sec_mat = array(724 => 2, 728=>3, 730=>2);
//$ret = Making::getMainMatTypelist($uid, 'cook');
$pos = 1;
//$uid = 108;
//$title = '234232';
//$class = 'cook';
//$product = 8;
//$technics = 5;
//$param = 1;
//$main_mat = array(1,11,21,301);
//$sec_mat = array(2004,2005,2007);
//$recipe_id = 66;
//$ret = Making::saveRecipe($uid, $title, $class, $product, $technics, $param, $main_mat, $sec_mat, $recipe_id);
$recipe_id = 87;
//$ret = Making::makeByRecipe($uid, $recipe_id);
$main_mat = array(4 => 5, 13=>5, 21=>5, 302=>5);
$sec_mat = array(2008 => 3, 2006=>2, 2007=>3);
//$ret = Making::make($uid, 'cook', $product, $technics, $param, $main_mat, $sec_mat);
//$uid = 68;
$staff_id = 75;
//$ret = Making::getRecipeList($uid, $staff_id);
$recipe_id = 31;
//$ret = Making::addRecipeExp($uid, $recipe_id);
//$ret = Making::recipeLvlUp($uid, $recipe_id);
//$ret = Making::calcPkResult($uid);
//var_export($ret);
//exit;
//exit;

//$ret = Titem::cache();
//$ret = Tbuilding::cache();
//exit;

//$ret = Gather::init($uid);
$pos = 1;
//$ret = Gather::getLvl($uid);
//$ret = Gather::getPosInfo($uid, $pos);
//$ret = Gather::getInfo($uid);
//$ret = Gather::lvlUp($uid, $tb_id);
//$ret = Gather::getList($uid);
$itemId = 401;
//$ret = Gather::work($uid, $itemId, $pos);
//$ret = Gather::harvest($uid, $pos);
//$ret = Gather::eradicate($uid, $pos);
//$ret = Gather::getSeedList($uid);
//var_export($ret);
//exit;


//$ret = Raise::init($uid);
$pos = 1;
$youngId = 1201;
//$uid = 99;
//$pos = 2;
//$ret = Raise::lay($uid, $youngId, $pos);
//$ret = Raise::getSpaceInfo($uid, $pos, 1);
//$ret = Raise::getLvl($uid, $type);
//$ret = Raise::getInfo($uid, $type);
//$ret = Raise::getList($uid);
//$uid = 113;
//$ret = Raise::lvlUp($uid);
//$ret = Raise::endGrowUp($uid, $pos);
//$ret = Raise::endSc($uid, $pos);
//$ret = Raise::getProduct($uid, $pos);
//$ret = Raise::eradicate($uid, $pos);
//$uid = 99;
$pos = 1;
//$depot_id = 1038;
$depot_id = 2032;
//$DB->beginTransaction();
//$DB->setTransactionState(false);
//$ret = Raise::feeding($uid, $pos, $depot_id);
//$DB->setTransactionState(true);
//$DB->rollBack();
//$ret = Raise::getSeedList($uid);
//$ret = Raise::steal(102, 1, $pos);
//var_export($ret);
//exit;




$pos = 1;
//$ret = FruitForest::init($uid);
//$ret = FruitForest::getHoleInfo($uid, $pos, 0);
//$ret = FruitForest::getInfo($uid);
//$ret = FruitForest::getList($uid);
//$ret = FruitForest::getLvl($uid);
//$ret = FruitForest::lvlUp($uid);
$seedId = 1102;
$pos = 5;
//$ret = FruitForest::plant($uid, $seedId, $pos);
//$ret = FruitForest::endGrowUp($uid, $pos);
//$ret = FruitForest::mature($uid, $pos);
$pos = 3;
//$ret = FruitForest::harvest($uid, $pos);
$val = 53;
//$ret = FruitForest::addVigorous($uid, $pos, $val);
//$nutrient_id = 3211;
//$ret = FruitForest::useNutrient($uid, $pos, $nutrient_id);
//$ret = FruitForest::getSeedList($uid);
//$ret = FruitForest::eradicate($uid, $pos);
//$ret = FruitForest::extend($uid);
//var_export($ret);
//exit;


//$ret = Farm::init($uid);
//$ret = Farm::getList($uid);
$pos = 1;
//$pos = 7;
//$ret = Farm::getPlowlandInfo($uid, $pos);
//$ret = Farm::getInfo($uid);
//$ret = Farm::getLvl(1);
//$ret = Farm::lvlUp($uid);
$seedId = 101;
//$ret = Farm::plant($uid, $seedId, $pos);
//$ret = Farm::mature($uid, $pos);
//$ret = Farm::harvest($uid, $pos);
//$ret = User::addProficiency($uid, 5555, 201, 3);
$pos = 3;
//$ret = Farm::harvest($uid, $pos);
//$ret = Farm::getFertiliserList($uid);
$fertiliser_id = 3112;
//$ret = Farm::fertilize($uid, $pos, $fertiliser_id);
//$ret = Farm::eradicate($uid, $pos);
//$ret = Farm::getSeedList($uid);
//$uid = 117;
//$to_uid = 113;
//$pos = 1;
//$ret = Farm::steal($uid, $to_uid, $pos);
//var_export($ret);
//exit;



$item_id = 1102;
$num = 1;
//$ret = Town::getCropSeedList($uid);
//$ret = Town::buyFruitSeed($uid, $item_id, $num);
//$ret = Town::getsecMatList($uid);
//var_export($ret);
//exit;





$type = '1';
$page = 2;
//$ret = Depot::getList($uid, $type, $page);
//$items = C('item/fertiliser');
$items = C('item/item_list');
//$i = 0;
//$DB->beginTransaction();
//foreach ($items as $itemId => $value) {
//	if ($value['type']==52 || $value['type']==53) continue;
//	if ($itemId > 2200) continue;
////	echo $itemId;
////	echo "\n";
////	continue;
//	for ($i=1; $i<=3; $i++) {
//		$data = array(
//			'item_id'	=> $itemId,
//			'item_type'	=> $value['type'],
//			'title'		=> $value['title'].$G['id_quality'][$i],
//			'num'		=> rand(110, 220),
//			'stack'		=> 1,
//			'quality'	=> $i,
//			'lvl'		=> $value['lvl'],
//		);
//		$ret = Depot::in($uid, $data);
//	}
//}
//$DB->commit();
//exit;
//var_export($ret);
//$data = array(
//	2 => 2,
//	4 => 4,
//	28 => 8,
//);
//$ret = Depot::out($uid, $data);
//$ret = generateOutputCfg(999, 9, 0.8, 'fruit_output');
//echo "\n";
//var_dump($uid);
//$ret = Depot::getFreeCapacity($uid);
//var_export($ret);
//exit;


C('build/making');
//var_export($G['make_class_list']);
//exit;
//$cfgList = C('item/gem');
$items = C('item/item_list');
//var_export($items);
//foreach ($items as $item_id=>$v) {
//	$classSign = array_rand($G['make_class_list']);
//	if ($v['type'] != 61 || $item_id < 10020) {
//		continue;
//	}
//	$info = $v;
	
	// 加宝石
//	$item_id = array_rand($cfgList);
//	$cfg = $cfgList[$item_id];
//	$num = 1;
//	$lvl = rand(1,10);
//	$abi_id = $cfg['add_attr_type'][$classSign];
//	$abi_val = $G['gem_lvl_val'][$lvl];
//	$attr = $abi_id.'='.$abi_val;
//	$data = array(
//		'item_id'	=> $i,
//		'item_type' => $info['type'],
//		'title'		=> $info['title'],
//		'num'		=> 1,
//		'quality'	=> 0,
//		'stack'		=> 1,
//		'lvl'		=> $lvl,
//		'color'		=> 0,
//		'part'		=> 0,
//		'attr'		=> $attr,
//	);
//	$data = array(
//		'item_id'	=> $item_id,
//		'item_type' => $info['type'],
//		'title'		=> $info['title'],
//		'num'		=> 1,
//		'quality'	=> 0,
//		'stack'		=> 0,
//		'lvl'		=> 0,
//		'color'		=> 0,
//		'part'		=> 1,
//		'attr'		=> '',
//	);
//	
//	$ret = Bag::in($uid, $data);
//	if (!$ret) {
//		var_dump($ret);
//		var_export($DB->errors);
//		exit;
//	}
//}




//$exp = 2000;
//$ret = User::addExp($uid, $exp);
//$ret = User::read(113);
//var_export($ret);
//exit;


echo "\n\n";
echo microtime(1) - $start;









